# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=gsad
pkgver=21.4.4
pkgrel=2
pkgdesc="Greenbone Security Assistant HTTP Server - The server talking to the Greenbone Vulnerability Management (GVM) deamon"
url="https://www.openvas.org/"
arch="all !riscv64" # limited by gsa
license="AGPL-3.0"
pkgusers="gvm"
pkggroups="gvm"
depends="gsa"
makedepends="cmake doxygen xmltoman graphviz gvm-libs-dev
	libxslt-dev libmicrohttpd-dev py3-polib libgcrypt-dev
	clang-dev glib-dev libxml2-dev"
checkdepends="cppcheck"
subpackages="$pkgname-doc $pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/greenbone/gsad/archive/refs/tags/v$pkgver.tar.gz
	fix-bin-path.patch
	$pkgname.initd
	$pkgname.logrotate"

build() {
	cmake -B build \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DSYSCONFDIR=/etc \
		-DGSAD_PID_PATH=/run/gsad/gsad.pid \
		-DLOCALSTATEDIR=/var \
		-DLOGROTATE_DIR=/etc/logrotate.d

	make -C build
}

check() {
	make -C build check
}

package() {
	make -C build DESTDIR="$pkgdir" install
	install -Dm644 "$srcdir"/$pkgname.logrotate "$pkgdir"/etc/logrotate.d/$pkgname
	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	rm -rf "$pkgdir"/lib/systemd
}

sha512sums="
092c8187754b3f0503e4ae6fd9c41dbd6917264668a5f8f831d40e88c7b8db6772acd354db62ac66b4af13b7c27e78516d4975f5bfede0d28001007a46c39f75  gsad-21.4.4.tar.gz
2004f92b395695684ea827afbee7d5177980491ae516f449630a848c9145cbffeb882836860e3d70944f34699a38a3e6739f926073d81284e29b2cb2f4ad861b  fix-bin-path.patch
70db1ef2b79dba7e13dd8d24acd0432828387e313fce4e922873cb95a958e7071c4731d32abd63453c4a7b397ea7433a1c52c478a893f99e3c14304dccfd6042  gsad.initd
ae2e030a4e0a6cb3022706d64d65990ee8fafb36dbff2e76478e68748a2c1deca1679408ea029140f08e0d32cf8060475f9c763a263252cff80a86047101dab0  gsad.logrotate
"
